<template>
	<!--当前界面为uni扩展navbar-->
	<view class="comp-base-pagination-box" v-if="isShowPagination">
		<uni-pagination class="page-pagination"
			:prevText="cPrevText" :nextText="cNextText" @change="_switchPage"
			:pageSize="cSize" :total="cTotal" :showIcon="cShowIcon" v-model="cPage">
		</uni-pagination>
	</view>
</template>

<script>
	export default {
		name: "c-base-pagination",
		props: {
			prevText: {
				type: String,
				default: ""
			},
			nextText: {
				type: String,
				default: ""
			},
			showIcon: {
				type: Boolean,
				default: false
			},
			pageSize: {
				type: Number,
				default: null
			},
			size: {
				type: Number,
				default: null
			},
			total: {
				type: Number,
				default: null
			}
		},
		data() {
			return {
				
			}
		},
		computed: {
			cPrevText() {
				return this.prevText || "上一页"
			},
			cNextText() {
				return this.nextText || "下一页"
			},
			cShowIcon() {
				return this.showIcon || false
			},
			cPage: {
				get() {
					return this.pageSize || 1
				},
				set(v) {
					this.$emit('update:pageSize', v)
				}
			},
			cSize() {
				return this.size || 10
			},
			cTotal() {
				return this.total || 0
			},
			isShowPagination() {
				let isShow = false
				if (this.cTotal && this.cTotal > this.cSize) {
					isShow = true
				}
				return isShow
			}
		},
		mounted() {
			
		},
		methods: {
			_switchPage(e) {
				this.$emit("change", e.current)
			}
		}
	}
</script>

<style scoped lang="scss">
	.comp-base-pagination-box {
		position: fixed;
		width: 100%;
		bottom: 70px;
	}
</style>
